import VueRouter from "vue-router";
import Vue from "vue";
import store from '@/store'
Vue.use(VueRouter);
let routes= [
  { path: "/", redirect: "/meetingRoomm1" },
  // 首页
  { path: "/meetingRoomm1", name:'meetingRoomm1',component: () => import("@/components/meetingRoomm1.vue"),meta:{nologin:true}},
  { path: "/meetingRoomm2", name:'meetingRoomm2',component: () => import("@/components/meetingRoomm2.vue"),meta:{nologin:true}},
  { path: "/meetingRoomm3", name:'meetingRoomm3',component: () => import("@/components/meetingRoomm3.vue"),meta:{nologin:true}},
  { path: "/meetingRoomm4", name:'meetingRoomm4',component: () => import("@/components/meetingRoomm4.vue"),meta:{nologin:true}},
  { path: "/meetingRoomm5", name:'meetingRoomm5',component: () => import("@/components/meetingRoomm5.vue"),meta:{nologin:true}},
]
//解决路由多次点击报错
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}
const router = new VueRouter({
  routes,
  mode: "hash",
});

/**
 * 路由拦截
 */
// router.beforeEach(function interceptor(to,from, next) {
//   if (to.meta.nologin) {
//     next();
//     return;
//   }
//   let token = store.getters["common/token"];
//   if (!!token) {
//     next();
//   } else {
//     router.push("/Shouye");
//     console.log("前端没有token");
//   }
// });
export default router
